package com.example.androidproject.net;


import com.example.androidproject.BuildConfig;
import com.example.androidproject.data.bean.UserInfoTools;
import com.hyg.idea.net.common.IdeaApiProxy;
import com.hyg.idea.net.token.IGlobalManager;
import com.hyg.idea.net.token.RefreshTokenResponse;


public class RetrofitHelper {

    private static IdeaApiService mIdeaApiService;

    public static IdeaApiService getApiService() {
        if (mIdeaApiService == null)
            mIdeaApiService = new IdeaApiProxy().getApiService(IdeaApiService.class,
                    BuildConfig.BASE_URL, new IGlobalManager() {
                        @Override
                        public void logout() {
                            UserInfoTools.logout();
                        }

                        @Override
                        public void tokenRefresh(RefreshTokenResponse response) {
                          UserInfoTools.updateToken(response);
                        }
                    });
        return mIdeaApiService;
    }
}
